package com.site.controller;

import com.site.common.R;
import com.site.common.annotation.IgnoreResponseDataAdvice;
import com.site.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 自定义忽略响应注解 @IgnoreResponseDataAdvice TEST
 */
@Slf4j
@RestController
public class ResponseTestController extends BaseController {

    /**
     * ResponseDataAdvice 返回处理后的数据
     * @return
     */
    @GetMapping("/response")
    public User test(){
        return User.builder().id(1).name("小二").build();
    }

    /**
     * 自定义忽略响应注解 @IgnoreResponseDataAdvice
     * @return
     */
    @GetMapping("/response4")
    public void test4(){
        log.info("执行了");
    }

    /**
     * 自定义忽略响应注解 @IgnoreResponseDataAdvice，直接输出 "<xml>OK</xml>"
     * @return
     */
    @IgnoreResponseDataAdvice
    @GetMapping("/response3")
    public String test3(){
        return "<xml>OK</xml>";
    }

    /**
     * 自定义忽略响应注解 @IgnoreResponseDataAdvice
     * @return
     */
    @IgnoreResponseDataAdvice
    @GetMapping("/response2")
    public R<String> test2(){
        return R.ok();
    }
}
